#!/bin/sh
#copy latest netcare-agent
sudo scp -r  $2@$1:$3/netcare/linux_32/netcare-agent /usr/bin/
#write init

echo "#!/bin/sh
start(){  
/usr/bin/netcare-agent &
echo  "service Netcare is started..." 
}     
stop(){  
killall netcare-agent 
echo  "service Netcare is stoped..." 
} 
  
case $"1" in   
start)   
start   
;;   
stop)   
stop   
;;   
*)   
echo "error choice ! please input start or stop";;   
esac   
exit 0" > /etc/init.d/netcare-agent
chmod +x /etc/init.d/netcare-agent #add netcare to run

#create connect in different run level
sudo update-rc.d netcare-agent start 98 2 3 5 .

#start netcare
sudo cp /root/Documents/netcare/netcare_version /usr/bin
sudo service netcare-agent start &
sudo sed -i '9i\-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 55555 -j ACCEPT' /etc/sysconfig/iptables
sudo service iptables restart

exit 1

